package com.ruoyi.project.hissystem.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.hissystem.domain.HisLogin;
import com.ruoyi.project.hissystem.service.IHisLoginService;
import com.ruoyi.project.monitor.domain.SysLogininfor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 高向前
 * @date : 9:46 2021/8/19
 */
@RestController
@RequestMapping("/hissystem/login")
public class HisLoginController  extends BaseController {
    @Autowired
    private IHisLoginService hisLoginService;


    @PreAuthorize("@ss.hasPermi('hissystem:login:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisLogin hisLogin)
    {
        System.out.println("0000000000000000000000000");
        startPage();
        List<HisLogin> list = hisLoginService.selectLoginList(hisLogin);
        return getDataTable(list);
    }

    @Log(title = "登录日志", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('hissystem:login:export')")
    @GetMapping("/export")
    public AjaxResult export(HisLogin hisLogin)
    {
        List<HisLogin> list = hisLoginService.selectLoginList(hisLogin);
        ExcelUtil<HisLogin> util = new ExcelUtil<HisLogin>(HisLogin.class);
        return util.exportExcel(list, "登录日志");
    }

    @PreAuthorize("@ss.hasPermi('hissystem:login:remove')")
    @Log(title = "登录日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{loginIds}")
    public AjaxResult remove(@PathVariable Long[] loginIds)
    {
        return toAjax(hisLoginService.deleteLoginByIds(loginIds));
    }

    @PreAuthorize("@ss.hasPermi('hissystem:login:remove')")
    @Log(title = "登录日志", businessType = BusinessType.CLEAN)
    @DeleteMapping("/clean")
    public AjaxResult clean()
    {
        hisLoginService.cleanLogin();
        return AjaxResult.success();
    }


}
